package com.tools.Fisco_tools;

import com.common.LO.EquityStructureTableLO;
import com.tools.Fisco.EquityStructureTable;
import lombok.extern.slf4j.Slf4j;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.model.TransactionReceipt;
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;

import java.math.BigInteger;
@Slf4j
public class EquityStructureTable_tools {
    public static TransactionReceipt insert(String address, Client client, CryptoKeyPair cryptoKeyPair, EquityStructureTableLO equityStructureTableLOBuilder) throws ContractException {
        EquityStructureTable load = EquityStructureTable.load(address, client, cryptoKeyPair);
        BigInteger bigInteger = new BigInteger(equityStructureTableLOBuilder.getShareholderNumber().toString());
       EquityStructureTable.Struct0 struct0 = new  EquityStructureTable.Struct0(
               equityStructureTableLOBuilder.getUnifiedSocialCreditCode(),
               equityStructureTableLOBuilder.getCompanyName(),
               equityStructureTableLOBuilder.getShareholder(),
               equityStructureTableLOBuilder.getShareholderAccount(),
               equityStructureTableLOBuilder.getOfferingType(),
               bigInteger
       );

        TransactionReceipt insert = load.insert(struct0);
        return  insert;
    }

}
